package com.imut.lagain.controller;

import com.imut.lagain.entity.MemoryEntry;
import com.imut.lagain.entity.MoodStealRecord;
import com.imut.lagain.entity.MoodThief;
import com.imut.lagain.service.IMoodThiefGameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
public class MoodThiefGameController {

    @Autowired
    private IMoodThiefGameService moodThiefGameService;

    // 执行偷取操作
    @PostMapping("/mood-thief-game/steal")
    public Map<String, Object> performSteal(@RequestParam Long thiefUserId, 
                                           @RequestParam Long victimUserId, 
                                           @RequestParam Long thiefId) {
        return moodThiefGameService.performSteal(thiefUserId, victimUserId, thiefId);
    }

    // 尝试追回被偷的心情
    @PostMapping("/mood-thief-game/recovery")
    public Map<String, Object> attemptRecovery(@RequestParam Long stealRecordId, 
                                              @RequestParam Long victimUserId) {
        return moodThiefGameService.attemptRecovery(stealRecordId, victimUserId);
    }

    // 获取可偷取的记忆条目
    @GetMapping("/mood-thief-game/stealable-entries")
    public List<MemoryEntry> getStealableEntries(@RequestParam Long victimUserId, 
                                                @RequestParam Long thiefUserId) {
        return moodThiefGameService.getStealableEntries(victimUserId, thiefUserId);
    }

    // 获取随机心情小偷
    @GetMapping("/mood-thief-game/random-thief")
    public MoodThief getRandomThief() {
        return moodThiefGameService.getRandomThief();
    }

    // 检查用户是否可以进行偷取操作
    @GetMapping("/mood-thief-game/can-steal")
    public boolean canSteal(@RequestParam Long thiefUserId, @RequestParam Long victimUserId) {
        return moodThiefGameService.canSteal(thiefUserId, victimUserId);
    }

    // 获取用户的偷取记录
    @GetMapping("/mood-thief-game/user-records")
    public List<MoodStealRecord> getUserStealRecords(@RequestParam Long userId, @RequestParam boolean isThief) {
        return moodThiefGameService.getUserStealRecords(userId, isThief);
    }

    // 获取偷取统计信息
    @GetMapping("/mood-thief-game/statistics")
    public Map<String, Object> getStealStatistics(@RequestParam Long userId) {
        return moodThiefGameService.getStealStatistics(userId);
    }
}